// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3) definits fieldsfirst ansi space safe 
// Source File Name:   CurrentSimulation.java

package jones;

import java.io.Serializable;
import java.util.*;

// Referenced classes of package jones:
//            SimpleRobot, Light, HockeyPuck, Wall, 
//            Simulation, World, Simulator

public class CurrentSimulation
    implements Simulation, Serializable
{

    private Simulation simulation = null;
    private List observables = null;
    private List robots = null;
    private List lights = null;
    private List hockeyPucks = null;
    private List walls = null;

    public CurrentSimulation(Simulation simulation)
    {
        this.simulation = null;
        this.observables = ((List) (new ArrayList()));
        robots = ((List) (new ArrayList()));
        lights = ((List) (new ArrayList()));
        hockeyPucks = ((List) (new ArrayList()));
        walls = ((List) (new ArrayList()));
        this.simulation = simulation;
        Observable observables[] = simulation.getObservables();
        for (int i = 0; i < observables.length; i++)
            this.observables.add(((Object) (observables[i])));

    }

    public Simulation copySimulation()
    {
        CurrentSimulation copy = new CurrentSimulation(simulation.copySimulation());
        for (int i = 0; i < robots.size(); i++)
            copy.addSimpleRobot(new SimpleRobot((SimpleRobot)robots.get(i), copy.getWorld()));

        for (int i = 0; i < lights.size(); i++)
            copy.addLight(new Light((Light)lights.get(i)));

        for (int i = 0; i < hockeyPucks.size(); i++)
            copy.addHockeyPuck(new HockeyPuck((HockeyPuck)hockeyPucks.get(i)));

        for (int i = 0; i < walls.size(); i++)
            copy.addWall(new Wall((Wall)walls.get(i)));

        return ((Simulation) (copy));
    }

    public Simulation createNewSimulation()
    {
        return ((Simulation) (new CurrentSimulation(simulation.createNewSimulation())));
    }

    public String getName()
    {
        return simulation.getName();
    }

    public World getWorld()
    {
        return simulation.getWorld();
    }

    public Simulator getSimulator()
    {
        return simulation.getSimulator();
    }

    public Observable[] getObservables()
    {
        return (Observable[])observables.toArray(((Object []) (new Observable[0])));
    }

    public void addSimpleRobot(SimpleRobot robot)
    {
        getWorld().addRigidBody(((jones.rigid.RigidBody) (robot)));
        getWorld().addSimObject(((SimObject) (robot)));
        getSimulator().addObservable(((Observable) (robot)));
        observables.add(((Object) (robot)));
        robots.add(((Object) (robot)));
    }

    public void addWall(Wall wall)
    {
        getWorld().addRigidBody(((jones.rigid.RigidBody) (wall)));
        getSimulator().addObservable(((Observable) (wall)));
        observables.add(((Object) (wall)));
        walls.add(((Object) (wall)));
    }

    public void addHockeyPuck(HockeyPuck hockeyPuck)
    {
        getWorld().addRigidBody(((jones.rigid.RigidBody) (hockeyPuck)));
        getSimulator().addObservable(((Observable) (hockeyPuck)));
        observables.add(((Object) (hockeyPuck)));
        hockeyPucks.add(((Object) (hockeyPuck)));
    }

    public void addLight(Light light)
    {
        getWorld().addLight(light);
        getSimulator().addObservable(((Observable) (light)));
        observables.add(((Object) (light)));
        lights.add(((Object) (light)));
    }

    public void removeObservable(Observable observable)
    {
        simulation.removeObservable(observable);
        observables.remove(((Object) (observable)));
        robots.remove(((Object) (observable)));
        lights.remove(((Object) (observable)));
        hockeyPucks.remove(((Object) (observable)));
        walls.remove(((Object) (observable)));
    }
}
